package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;

import com.bjesc_b2c.app.appraiset.R;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;
import master_bean.CarForBean;

/**
 * Created by Jason Chen on 2017/2/22.
 */

public class CarfromOneAdapter extends CommonAdapter<CarForBean> {
    public static int TYPE_ONE  = 1;
    public static int TYPE_TWO  = 2;
    public static int TYPE_THREE  = 3;
    private int type;
    public CarfromOneAdapter(Context context, int layoutId, List<CarForBean> datas, int type) {
        super(context, layoutId, datas);
        this.type = type;
    }

    @Override
    protected void convertView(ViewHolder holder, CarForBean bean, int position) {
//        holder.setText(R.id.tv_carfrom_one, bean.getName());
//        if (bean.isCheck()) {
//            holder.setTextColorRes(R.id.tv_carfrom_one, R.color.colorFFFF7900);
//        } else {
//            holder.setTextColorRes(R.id.tv_carfrom_one, R.color.colorFF030303);
//        }
        if (type == TYPE_ONE){
            holder.setText(R.id.tv_car_brand_name, bean.getName());
            if (bean.isCheck()) {   //设置选中效果
                holder.setBackgroundRes(R.id.tv_car_brand_name, R.color.colorFFF1F1F1);
            } else {
                holder.setBackgroundRes(R.id.tv_car_brand_name, R.color.colorWhite);
            }
            if (position != 0) {
                if (mDatas.get(position).getFirstLetter().equals(mDatas.get(position - 1).getFirstLetter())) {  //参数后一位与前一位字母相同
                    holder.setVisible(R.id.tv_letter, false);
                } else {
                    holder.setText(R.id.tv_letter, bean.getFirstLetter());
                    holder.setVisible(R.id.tv_letter, true);
                }
            } else {
                holder.setText(R.id.tv_letter, bean.getFirstLetter());
                holder.setVisible(R.id.tv_letter, false);
            }
    }else if(type ==TYPE_TWO){
        holder.setText(R.id.tv_carfrom_one,bean.getName());
    }else if(type ==TYPE_THREE){
            holder.setText(R.id.tv_carfrom_one,bean.getMarket_name());
        }
        }

}
